home *** CD-ROM | disk | FTP | other *** search
- /*
- * $RCSfile: notify.c,v $
- * $Revision: 1.1.1.1 $
- * $Date: 1996/05/04 21:55:59 $
- */
- /**********************************************************************
- * EXODUS Database Toolkit Software
- * Copyright (c) 1991 Computer Sciences Department, University of
- * Wisconsin -- Madison
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
- * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.
- * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
- * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * The EXODUS Project Group requests users of this software to return
- * any improvements or extensions that they make to:
- *
- * EXODUS Project Group
- * c/o David J. DeWitt and Michael J. Carey
- * Computer Sciences Department
- * University of Wisconsin -- Madison
- * Madison, WI 53706
- *
- * or exodus@cs.wisc.edu
- *
- * In addition, the EXODUS Project Group requests that users grant the
- * Computer Sciences Department rights to redistribute these changes.
- **********************************************************************/
-
- #include "sysdefs.h"
- #include "ess.h"
- #include "checking.h"
- #include "trace.h"
- #include "error.h"
- #include "list.h"
- #include "tid.h"
- #include "io.h"
- #include "lock.h"
- #include "object.h"
- #include "msgdefs.h"
- #include "thread.h"
- #include "bitvec.h"
- #include "thread_funcs.h"
- #include "thread_globals.h"
- #include "threadstate.h"
-
-
- void
- notify (
-
- register LIST *list,
- register int error,
- register int eno
-
- )
- {
-
- register TCB *tcb;
-
-
- TRPRINT(TR_THREAD, TR_LEVEL_1, ("error:%d", error));
-
- /*
- * attempt to get a thread off the ready list
- */
- while ((tcb = (TCB *) listDeq(list)) != NULL) {
-
- TRPRINT(TR_THREAD, TR_LEVEL_2, ("dispatching thread:%d", tcb->id));
-
- #ifdef DEBUG
- /*
- * Make sure the thread is waiting on something that
- * notify is currently allowed to wakeup. Other types
- * of waiters could be notified, but these are the only
- * ones in the current implementation.
- */
- switch (tcb->state) {
- case THREAD_SH_LATCH_WAIT:
- case THREAD_EX_LATCH_WAIT:
- case THREAD_LOCK_WAIT:
- case THREAD_LOCKUPGRADE_WAIT:
- case THREAD_LOG_QUIESCE_WAIT:
- case THREAD_LOG_PREFLUSH_WAIT:
- case THREAD_BUFGROUP_WAIT:
- case THREAD_LOG_RECOVERY_WAIT:
- case THREAD_CHECKPOINT_WAIT:
- case THREAD_DISKOPEN_WAIT:
- case THREAD_DISKCLOSE_WAIT:
- case THREAD_LOG_CLOSE_WAIT:
- case THREAD_TRANS_SHUTDOWN_WAIT:
- case THREAD_RECOVER_UNDO_WAIT:
- case THREAD_PAGEFLUSH_WAIT:
- case THREAD_FORK_WAIT:
- case THREAD_COORD_WAIT:
- break;
-
- /* only on error */
- case THREAD_SEMAPHORE_WAIT:
- case THREAD_DISK_WAIT:
- case THREAD_RECEIVE_WAIT:
- case THREAD_DISK_Q_WAIT:
- SM_ASSERT(LEVEL_3, error != esmNOERROR);
- SM_ASSERT(LEVEL_3, eno != esmNOERROR);
- break;
-
- default:
-
- /* notify is not used to wake these threads */
- SM_ERROR(TYPE_FATAL, esmINTERNAL);
- }
- #endif DEBUG
-
- /*
- * take the thread off the list and put in ready list
- */
- listEnq( &ReadyList, &(tcb->controlList) );
- tcb->error = error;
- tcb->errno = eno;
- }
- }
-